<template>
  <div id="app">
    <!-- 头部区域 -->
    <v-header :seller="this.seller"></v-header>
    <!-- 导航区域 -->
    <div class="tab border-1px">
      <ul>
        <router-link to="/goods" tag="li">商品</router-link>
        <router-link to="/ratings" tag="li">评价</router-link>
        <router-link to="/seller" tag="li">商家</router-link>
      </ul>
    </div>
    <!-- 内容区域 -->
    <keep-alive>
      <!-- 因为子组件使用better-scroll，要通过seller计算width属性，
      v-if="seller.name"确保seller已经获取完毕后再开始渲染子组件， -->
      <router-view v-if="seller.name" :seller="seller"></router-view>
    </keep-alive>
    <shopcar :minPrice="seller.minPrice" :deliveryPrice="seller.deliveryPrice"></shopcar>
  </div>
</template>
<script>
// 所有的组件都以v-开头，表示是vue的组件，避免冲突
import header from "./components/header/header";
import shopcar from "./components/shopcar/shopcar";
import { urlParse } from "./common/js/util.js";
export default {
  name: "App",
  data() {
    return {
      seller: {
        id: (() => {
          let queryParam = urlParse();
          return queryParam.id;
        })(),
        name: "粥品香坊（回龙观）",
        description: "蜂鸟专送",
        deliveryTime: 38,
        score: 4.2,
        serviceScore: 4.1,
        foodScore: 4.3,
        rankRate: 69.2,
        minPrice: 20,
        deliveryPrice: 4,
        ratingCount: 24,
        sellCount: 90,
        bulletin:
          "粥品香坊其烹饪粥料的秘方源于中国千年古法，在融和现代制作工艺，由世界烹饪大师屈浩先生领衔研发。坚守纯天然、0添加的良心品质深得消费者青睐，发展至今成为粥类的引领品牌。是2008年奥运会和2013年园博会指定餐饮服务商。",
        supports: [
          {
            type: 0,
            description: "在线支付满28减5"
          },
          {
            type: 1,
            description: "VC无限橙果汁全场8折"
          },
          {
            type: 2,
            description: "单人精彩套餐"
          },
          {
            type: 3,
            description: "该商家支持发票,请下单写好发票抬头"
          },
          {
            type: 4,
            description: "已加入“外卖保”计划,食品安全保障"
          }
        ],
        avatar:
          "http://static.galileo.xiaojukeji.com/static/tms/seller_avatar_256px.jpg",
        pics: [
          "http://fuss10.elemecdn.com/8/71/c5cf5715740998d5040dda6e66abfjpeg.jpeg?imageView2/1/w/180/h/180",
          "http://fuss10.elemecdn.com/b/6c/75bd250e5ba69868f3b1178afbda3jpeg.jpeg?imageView2/1/w/180/h/180",
          "http://fuss10.elemecdn.com/f/96/3d608c5811bc2d902fc9ab9a5baa7jpeg.jpeg?imageView2/1/w/180/h/180",
          "http://fuss10.elemecdn.com/6/ad/779f8620ff49f701cd4c58f6448b6jpeg.jpeg?imageView2/1/w/180/h/180"
        ],
        infos: [
          "该商家支持发票,请下单写好发票抬头",
          "品类:其他菜系,包子粥店",
          "北京市昌平区回龙观西大街龙观置业大厦底商B座102单元1340",
          "营业时间:10:00-20:30"
        ]
      }
    };
  },
  // -----------------获取数据
  // methods: {
  //   getHeader() {
  //     this.$http.get("/api/seller?id=" + this.seller.id).then(result => {
  //       if (result.status === 200) {
  //         this.seller = Object.assign({}, this.seller, result.body.data);
  //       }
  //     });
  //   }
  // },
  // created() {
  //   this.getHeader();
  // },
  components: {
    "v-header": header,
    shopcar
  }
};
</script>
<style lang="less">
@import "./common/css/common.less";
#app {
  height: 100%;
  overflow: hidden;
  .tab {
    height: 40px;
    width: 100%;
    .border-1px( rgba(7, 17, 27, 0.1));
    ul {
      display: flex;
      justify-content: space-around;
      li {
        flex-grow: 1;
        text-align: center;
        font-size: 14px;
        line-height: 40px;
        color: rgb(77, 85, 93);
        //为点击的tab设置高亮
        &.active {
          color: rgb(240, 20, 20);
        }
      }
    }
  }
}
</style>
